package com.tkk.monitoring.filter;

import com.tkk.monitoring.analyze.AnalyzeManager;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.*;
import org.littleshoot.proxy.HttpFilters;

/**
 * author: Tkk
 * date: 2015/7/7
 */
public class FilterChain implements HttpFilters {

    private HttpRequest request;
    private ChannelHandlerContext channelHandlerContext;

    public FilterChain(HttpRequest httpRequest, ChannelHandlerContext channelHandlerContext) {
        this.request = httpRequest;
        this.channelHandlerContext = channelHandlerContext;
    }

    @Override
    public HttpResponse requestPre(HttpObject httpObject) {
        return null;
    }

    @Override
    public HttpResponse requestPost(HttpObject httpObject) {
        if (httpObject instanceof DefaultFullHttpRequest){
            AnalyzeManager.start((DefaultFullHttpRequest) httpObject);
        }
        return null;
    }

    @Override
    public HttpObject responsePre(HttpObject httpObject) {
        return httpObject;
    }

    @Override
    public HttpObject responsePost(HttpObject httpObject) {
        return httpObject;
    }
}
